﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace EarthWorm
{
    class WebClientEx : WebClient
    {
        private readonly long from;
        private readonly long to;

        public WebClientEx(long from, long to)
        {
            this.from = from;
            this.to = to;
        }

        protected override WebRequest GetWebRequest(Uri address)
        {
            var request = (HttpWebRequest)base.GetWebRequest(address);
            if (this.from != 0)
            {
                if (this.to == 0)
                    request.AddRange(this.from);
                else
                    request.AddRange(this.from, this.to);
            }
            return request;
        }
    }
}
